package LeetCode;

public class LC_141_LinkedListCycle {

    public static void main(String[] args) {

    }

    static class Solution {
        public boolean hasCycle(ListNode head) {
            if (head == null || head.next == null)
                return false;
            ListNode curr = head;
            ListNode sec = head;

            while (sec.next != null && sec.next.next != null) {
                curr = curr.next;
                sec = sec.next.next;
                if (curr == sec) return true;
            }
            return false;
        }
    }
}